package com.zzgele.qmzb.api.web;

import com.alibaba.boot.dubbo.annotation.DubboConsumer;
import com.github.pagehelper.PageInfo;
import com.zzgele.qmzb.api.core.Constants;
import com.zzgele.qmzb.api.core.Result;
import com.zzgele.qmzb.api.core.ResultGenerator;
import com.zzgele.qmzb.api.service.DiamondRechargeLogService;
import com.zzgele.qmzb.api.service.UserService;
import com.zzgele.qmzb.api.service.WithdrawalsLogService;
import com.zzgele.qmzb.api.utils.PageUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;

/**
 * Created by Martin on 2017/07/09.
 */
@RestController
public class moneyController {
    private final Logger logger = LoggerFactory.getLogger(moneyController.class);
    @DubboConsumer
    private UserService userService;
    @DubboConsumer
    private DiamondRechargeLogService diamondRechargeLogService;

    @DubboConsumer
    private WithdrawalsLogService withdrawalsLogService;

    @PostMapping("/user/withdrawals/log/list")
    public Result log_list(Long login_uid, Integer page, Integer page_size) {
        PageUtil.startPage(page, page_size);
//        Map<String, Object> map = new HashMap();
//        map.put("uid", login_uid);
        List<HashMap> diamondRechargeLogList = withdrawalsLogService.list(login_uid);
        
        HashMap diamondRechargeLogListHashMap = PageUtil.getPageInfoHashMap(new PageInfo(diamondRechargeLogList));

        return ResultGenerator.genSuccessResult(diamondRechargeLogListHashMap);
    }
    

    @PostMapping("/user/withdrawals_proportion") //进入提现页面（返回提现比例）
    public Result withdrawals_proportion() {
        HashMap hashMap = new HashMap();
        hashMap.put("proportion", Constants.COMMISSION_CHARGE);
        return ResultGenerator.genSuccessResult(hashMap);
    }

    

}
